<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateDistributorsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('distributors', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name', 190)->index()->nullable()->comment('分销员姓名');
            $table->string('mobile',20)->index()->nullable()->comment('分销员手机');
            $table->string('promo_code',50)->index()->nullable()->comment('分销员推广码');
            $table->text('promo_code_url')->nullable()->comment('分销员推广码图片地址');
            $table->integer('distributor_level_id')->index()->default(1)->comment('分销员等级ID');
            $table->integer('total_amount')->index()->default(0)->comment('总佣金 单位：分');
            $table->integer('usable_amount')->index()->default(0)->comment('可用佣金 单位：分');
            $table->integer('frozen_amount')->index()->default(0)->comment('冻结佣金 单位：分');
            $table->integer('used_amount')->index()->default(0)->comment('已提现佣金 单位：分');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('distributors');
    }
}
